home *** CD-ROM | disk | FTP | other *** search
/ PC Elektro 3 / PC-Elektro-3-cd1.bin / KBan 2.0 / KBANSRC.LZH / SRC / PROG / CMD / PLLINE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1997-09-14  |  2.8 KB  |  112 lines

  1. /*
  2.  * the class PLACE_LINE
  3.  * Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
  4.  */
  5.  
  6. #include "../stdafx.h"
  7.  
  8. #include "../common/bool.h"
  9.  
  10. #include "plline.h"
  11.  
  12. void PLACE_LINE::PLACE_LINE_MOUSE_CURSOR::draw_cursor_core(KBAN_DRAW& draw, const LINE_ELEMENT& target)
  13. {
  14.   draw.draw_primitive_line_cursor(target);
  15. }
  16.  
  17. STAGE* PLACE_LINE::init_new(KBAN_INFO& info, KBAN_DRAW& draw)
  18. {
  19.   return new STAGE_INITIAL;
  20. }
  21.  
  22. const char* PLACE_LINE::get_name(void)
  23. {
  24.   return "Place:Line";
  25. }
  26.  
  27. STAGE* PLACE_LINE::STAGE_INITIAL::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  28. {
  29.   XY ac;
  30.   info.grid().xy_pc2ac(pc, ac);
  31.   return new STAGE_PLACE_LINE(ac);
  32. }
  33.  
  34. STAGE* PLACE_LINE::STAGE_INITIAL::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  35. {
  36.   return NULL;
  37. }
  38.  
  39. PLACE_LINE::STAGE_PLACE_LINE::STAGE_PLACE_LINE(const XY& ac_s)
  40.   : m_ac_s(ac_s) {}
  41.  
  42. STAGE* PLACE_LINE::STAGE_PLACE_LINE::init(KBAN_INFO& info, KBAN_DRAW& draw)
  43. {
  44.   info.bCaptured() = true;
  45.   return this;
  46. }
  47.  
  48. STAGE* PLACE_LINE::STAGE_PLACE_LINE::pre_redraw(KBAN_INFO& info, KBAN_DRAW& draw)
  49. {
  50.   // m_mcur.erase_cursor(draw);
  51.   return this;
  52. }
  53.  
  54. STAGE* PLACE_LINE::STAGE_PLACE_LINE::redraw(KBAN_INFO& info, KBAN_DRAW& draw)
  55. {
  56.   m_mcur.redraw_cursor(draw);
  57.   return this;
  58. }
  59.  
  60. STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_move(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  61. {
  62.   XY ac_e;
  63.   info.grid().xy_pc2ac(pc, ac_e);
  64.   LINE_ELEMENT current(m_ac_s, ac_e, info.apt_line().width());
  65.   m_mcur.draw_cursor(draw, current);
  66.   return this;
  67. }
  68.  
  69. STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_left_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  70. {
  71.   m_mcur.erase_cursor(draw);
  72.  
  73.   XY ac_e;
  74.   info.grid().xy_pc2ac(pc, ac_e);
  75.  
  76.   STAGE* ret;
  77.  
  78.   if(m_ac_s != ac_e) {
  79.     PRIMITIVE& primitive = info.kban_data().primitive();
  80.     LINE_LIST& line_list = primitive.layer(info.active_layer().get()).line_list();
  81.  
  82.     LINE_ELEMENT line_element(m_ac_s, ac_e, info.apt_line().width());
  83.     line_list.push_back(line_element);
  84.     info.SetModifiedFlag();
  85.     info.new_state().set(true);
  86.     info.new_state_str() = "Place Line";
  87.  
  88.     draw.draw_primitive_line(line_element, info.active_layer().get());
  89.  
  90.     info.bCaptured() = false;
  91.     ret = new STAGE_PLACE_LINE(ac_e);
  92.   } else {
  93.     AfxGetMainWnd()->MessageBox("Origin and destination are the same point.", "Place Line");
  94.  
  95.     ret = this;
  96.   }
  97.   return ret;
  98. }
  99.  
  100. STAGE* PLACE_LINE::STAGE_PLACE_LINE::mouse_right_up(KBAN_INFO& info, KBAN_DRAW& draw, const XY& pc, UINT nFlags)
  101. {
  102.   m_mcur.erase_cursor(draw);
  103.   info.bCaptured() = false;
  104.   return new STAGE_INITIAL;
  105. }
  106.  
  107. void PLACE_LINE::STAGE_PLACE_LINE::end(KBAN_INFO& info, KBAN_DRAW& draw)
  108. {
  109.   m_mcur.erase_cursor(draw);
  110.   info.bCaptured() = false;
  111. }
  112.